<{include file="../common/iframe_head.tpl"}>
<link href="//unpkg.com/layui@2.11.5/dist/css/layui.css" rel="stylesheet">
<script src="//unpkg.com/layui@2.11.5/dist/layui.js"></script>
<form name='myForm1' id='myForm1' method='post' action='/benchmark/DoDuibiao'>
    <div style='margin:10px;'>
        <table>
            <tr>
                <td width="50px"><b>题目：</b></td>
                <td><b><{$subject_info.question_num}><{$subject_info.title}></b></td>
            </tr>
            <!--<tr>
                <td>是否申请还分：</td>
                <td><input name='isreturn' type='radio' value='0' <{if $info.isreturn==0}>checked="checked"<{/if}> />否
                    <input type="radio" name="isreturn" value="1" <{if $info.isreturn==1}>checked="checked"<{/if}> />是
                </td>
            </tr>-->
            <tr>
                <td width="50px">申诉内容：</td><td><textarea name='suggestion' cols='65' rows='10'><{$info.suggestion}></textarea></td>
            </tr>
            <tr>
                <td width="50px">附件：</td>
                <td><br/>
                    <div class="layui-btn-container">
                        <button type="button" class="layui-btn layui-btn-normal" id="uploadify">选择文件</button>
                        <button type="button" class="layui-btn" id="ID-upload-demo-action">开始上传</button>
                        <br/>(格式不限，总大小限制10M，上传速度与网速有关)
                    </div>

                    <{if $info.haveattach==1}>
                    <ul>
                        <{foreach $attachlist as $key => $val}>
                        <li id="attach_<{$val.qba_id}>"><{$val.filename}>&nbsp;&nbsp;&nbsp;&nbsp;<a href="<{$val.url}>" target="_blank">下载</a>&nbsp;<a href="javascript:;" onclick="del(<{$val.qba_id}>);">删除</a></li>
                        <{/foreach}>
                    </ul>
                    <{/if}>
                </td>
            </tr>
            <tr><td colspan='2'><input type='submit' class="layui-btn layui-btn-primary layui-border-green layui-btn-lg" value='提交' style="margin-left:100px;"></td></tr>
        </table>
        <input type='hidden' name='subject_id' value='<{$subject_id}>' />
        <input name='nq_id' type='hidden' value='<{$nq_id}>' />
        <input name='qb_id' type='hidden' value='<{$info.qb_id}>' />
    </div>
</form>
<script>

    layui.use(function(){
        var upload = layui.upload;
        var layer = layui.layer;
        // 渲染
        upload.render({
            data:{'nq_id' : <{$nq_id}>, 'subject_id' : <{$subject_id}>,'network_id':<{$network_id}>},
            dataType :'text',
            elem: '#uploadify',
            url: '/attachment/duibiaoAttach?attach_type=benchmark',
            auto: false,
            field:'upfile',
            size:11000,
            accept:'file',
            // multiple: true,
            bindAction: '#ID-upload-demo-action',
            done: function(res){
                var obj = eval('(' + res + ')');
                if (obj.state == 'SUCCESS') {
                    layer.msg('上传成功');
                } else {
                    layer.msg(obj.note);
                }
            }
        });
    });

    var project_email = "超大文件上传请联系项目邮箱<{$project.email}>";
    $(document).ready(function() {
        var options = {
            beforeSubmit:  showRequest,
            success:       showResponse,
            dataType:  'json'
        }
        $('#myForm1').ajaxForm(options);


        $('#uploadify').uploadify({
            'fileSizeLimit' : '10MB',
            'formData'      : {'nq_id' : <{$nq_id}>, 'subject_id' : <{$subject_id}>,'network_id':<{$network_id}>},
            'buttonText' : '选择文件',
            'fileObjName' : 'upfile',
            'swf'      : '/js/uploadify.swf',
            'fileTypeExts' : '*.*',
            'uploader' : '/attachment/duibiaoAttach?attach_type=benchmark',
            'onUploadSuccess' : function(file, data, response) {
                var obj = eval('(' + data + ')');
                if (obj.state =='SUCCESS'){
                    alert('上传成功');
                } else {
                    alert(obj.note);
                }
            }
        });
    });
    function showRequest(formData, jqForm, options) {
        return true;
    }
    function showResponse(responseText, statusText, xhr, $form)  {
        alert(responseText.note);
        if (responseText.status==1) {
            window.parent.thisPage = false;
            <{if $iframe==1}>
                window.parent.location.reload();
                <{else}>
                    window.parent.location.href='<{$referer}>&subject_id=<{$subject_info.subject_id}>';
                    <{/if}>
                        }
                        }
                        //删除附件
                        function del(qba_id){
                        if (confirm('确定删除此附件！')) {
                        $.getJSON('/benchmark/DelBenchAttach',{qba_id:qba_id},function(res){
                        if (res.status==1) {
                        $('#attach_'+qba_id).remove();
                    }
                        alert(res.note);
                    });
                    }
                    }
</script>
<{include file="../common/footer.tpl"}>